package utils.test.img;

import java.awt.image.BufferedImage;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

import javax.imageio.ImageIO;

import lion.dev.image.DefaultImageHandler;
import lion.dev.image.gif.GifDecoder;

/**
 * @author lion
 * @date 2016年9月24日
 */
public class FindTransparent {

	public static void main(String[] args) throws IOException {

		GifDecoder decoder = new GifDecoder();
		System.out.println(decoder.read(new FileInputStream("D:/2.gif")));
		BufferedImage image = decoder.getFrame(1);

		ImageIO.write(image, "png", new FileOutputStream("D:/x.png"));

		image = DefaultImageHandler.resize(image, image.getWidth() / 2, image.getHeight() / 2);
		for (int y = image.getMinY(); y < image.getHeight(); y++) {
			for (int x = image.getMinX(); x < image.getWidth(); x++) {
				int rgb = image.getRGB(x, y);
				System.out.print("#" + Integer.toHexString(rgb) + ",");
				// if (rgb == 0xffffff) {
				// System.out.println("find it ");
				// break;
				// }
			}
			System.out.println("");
		}

	}

}
